<%@ page import="com.ws.haungjia.utils.Res" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>旅游系统注册</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #333;
        }

        .container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 30px;
            width: 350px;
            text-align: center;
        }

        .avatar-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
        }

        .avatar-preview {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            overflow: hidden;
            border: 3px solid #e0e0e0;
            margin-bottom: 10px;
            position: relative;
            background-color: #f8f8f8;
        }

        .avatar-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .avatar-upload-btn {
            display: inline-block;
            padding: 6px 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }

        .avatar-upload-btn:hover {
            background-color: #45a049;
        }

        #avatar-input {
            display: none;
        }

        h1 {
            color: #333;
            font-size: 24px;
            margin-bottom: 5px;
        }

        .welcome {
            color: #666;
            font-size: 16px;
            margin-bottom: 20px;
        }

        .form-title {
            font-size: 18px;
            margin-bottom: 25px;
            color: #444;
        }

        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: #555;
        }

        input[type="text"],
        input[type="password"],
        input[type="tel"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 14px;
        }

        .checkbox-group {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }

        .checkbox-group input {
            margin-right: 8px;
        }

        .checkbox-group label {
            margin-bottom: 0;
            font-size: 13px;
        }

        .register-btn {
            width: 100%;
            padding: 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            margin-bottom: 15px;
            transition: all 0.3s;
        }

        .register-btn:hover {
            background-color: #45a049;
        }

        .login-link {
            font-size: 14px;
            color: #666;
        }

        .login-link a {
            color: #4CAF50;
            text-decoration: none;
        }

        .avatar-hint {
            font-size: 12px;
            color: #888;
            margin-top: 5px;
        }
    </style>
</head>
<body>
<div class="container">
    <p class="form-title">个人中心</p>

    <form action="${ pageContext.request.contextPath}/geren/xiugai" method="post" enctype="multipart/form-data">
        <input type="hidden" name="id" value="${user.userID}">
        <img src="<%=Res.fileUri%>${user.touxiang}" width="100px" height="100px"><br>
       选择新头像:<input type="file" name="touxaing">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="name" value="${user.name}" required>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="text" id="password" name="mima" value="" required>
        </div>

        <div class="form-group">
            <label for="phone">手机号</label>
            <input type="tel" id="phone" name="shouji" value="${user.shouji}" required>
        </div>

        <div class="checkbox-group">
            <input type="checkbox" id="agreement" name="agreement" required>
            <label for="agreement">我已阅读并同意用户协议和隐私政策</label>
        </div>

        <button type="submit" class="register-btn">立即修改</button>
    </form>
</div>

<script>
    // 头像预览功能
    document.getElementById('avatar-input').addEventListener('change', function(e) {
        const file = e.target.files[0];
        if (file) {
            if (file.size > 2 * 1024 * 1024) {
                alert('文件大小不能超过2MB');
                return;
            }

            const reader = new FileReader();
            reader.onload = function(event) {
                document.getElementById('avatar-preview').src = event.target.result;
            };
            reader.readAsDataURL(file);
        }
    });
</script>
</body>
</html>